<?php

namespace App\Api;

use App\Http\Controllers\Controller;
use App\Http\Resources\OrderResource;
use App\Models\Order;
use Illuminate\Http\Request;

class OrderController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return OrderResource::collection(Order::paginate(5));
    }


    /**
     *
     * 创建桌台，创建订单
     * @param \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request, Order $order)
    {
        $order->create($request->input());
        return $this->message('开台成功');
    }


    public function show(Order $order)
    {
        //
    }


    public function edit(Order $order)
    {
        //
    }


    public function destroy(Order $order)
    {
        //
    }

    public function noPaid()
    {
        $desks = OrderResource::collection(Order::select('id', 'name', 'desk_id')
            ->where('status', '=', 'nopay')->get());
        return $desks;
    }
}
